package com.cloudsigns.factorymanager2.engineering.presenter;

import com.cloudsigns.factorymanager2.engineering.IView.IPauseOrResetMediaForPublicationView;
import com.cloudsigns.factorymanager2.engineering.model.IPauseOrResetMediaForPublicationModel;
import com.cloudsigns.factorymanager2.engineering.model.PauseOrResetMediaForPublicationModel;

/**
 * Created by tony on 2018/6/17.
 */

public class PauseOrResetMediaForPublicationPresenter {

    private IPauseOrResetMediaForPublicationView view;
    private IPauseOrResetMediaForPublicationModel model;
    private android.os.Handler mHandler = new android.os.Handler();

    public PauseOrResetMediaForPublicationPresenter(IPauseOrResetMediaForPublicationView view) {
        this.view = view;
        this.model = new PauseOrResetMediaForPublicationModel();
    }

    public void pauseOrResetMediaForPublication() {


        model.pauseOrResetMediaForPublication(view.gethasPauseOrder(),view.getitemId(), view.getOrderId(),new PauseOrResetMediaForPublicationModel.OnPauseOrResetMediaForPublicationListener() {
            @Override
            public void pauseOrResetMediaForPublicationSuccessed() {
                //需要在UI线程执行
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.pauseOrResetMediaForPublicationViewSuccessed();
                        view.hideLoading();
                    }
                });
            }

            @Override
            public void pauseOrResetMediaForPublicationFailed(final String desc) {
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.pauseOrResetMediaForPublicationViewFailed(desc);
                        view.hideLoading();
                    }
                });
            }


        });
    }
}
